#ifndef __COMM_HPP__
#define __COMM_HPP__
#include<iostream>
#include<string>
#include<sys/types.h>
#include<sys/stat.h>
#include<cerrno>
#include<cstring>
#include <unistd.h>
#include<fcntl.h>
using namespace std;
#define Mode 0666
#define Path "./fifo"
class Fifo
{
public:
Fifo(const string& path):
_path(path)
{
    umask(0);
    int n = mkfifo(_path.c_str(),Mode);
    if(n==0)
    {
        cout<<"mkfifo success"<<endl;
        
    }
    else
    {
        cout<<"mkfifo fail ";
        cout<<"errno: "<<errno<<" err string"<<strerror(errno)<<endl;
    }
}
~Fifo()
{
    int n = unlink(_path.c_str()); // 可以用于删除普通文件和删除链接文件.
    if(n==0)
    {
        cout<<"remove fifo"<<_path.c_str()<<"success!"<<endl;
    }
    else
    {
        cout<<"remove fifo error errno:"<<errno<<"error string"<<strerror(errno)<<endl;
    }
}

private:
    string _path; //  文件路径+ 文件名
};

#endif